<style type="text/css">
    .layui-table-body{overflow-x:auto;}
    .layui-table-cell{font-size:12px;}
</style>
<div class="layui-form hisi-search">
    <form action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">关键词</label>
            <div class="layui-input-inline">
                <input type="text" name="keyword" class="layui-input" lay-verify="required" placeholder="订单号" class="keyword"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分类</label>
            <div class="layui-input-inline">
                <select name="status" class="status">
                    <option value="0">所有订单</option>
                    <option value="1">待支付订单</option>
                    <option value="2">待发货订单</option>
                    <option value="3">待收货订单</option>
                    <option value="4">已完成订单</option>
                    <option value="5">退款订单</option>
                    <option value="6">积分商城订单</option>
                    <option value="7">申请开票订单</option>
                    <option value="8">已开票订单</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
                <input class="layui-input" id="bg_time" type="text" placeholder="选择下单开始时间" name="bg_time">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
                <input class="layui-input" id="ed_time" type="text" placeholder="选择下单结束时间" name="ed_time">
            </div>
        </div>
        
        <div class="layui-form-item hisi-search-btn">
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-normal layui-icon layui-icon-search">查询</button>
            </div>
        </div>
    </form>
</div>
<table id="dataTable"></table>

{include file="system@block/layui" /}
<script id="toolbar" type="text/html">
    <!-- <a href="{:url('add')}?type=goods" class="layui-btn layui-btn-normal layui-btn-sm hisi-iframe-pop" hisi-data="{width: '1000px', height: '500px', title: '添加商品'}">&nbsp;添加</a> -->
    <button  class="layui-btn layui-btn-primary layui-icon layui-icon-play" id="export-id" onclick="javascript:export_data();">&nbsp;导出</button>
    <!-- <button type="button" class="layui-btn" id="test1">
        <i class="layui-icon">&#xe67c;</i>导入excel
      </button> -->
</script>
<script type="text/javascript">
    var $ = layui.jquery;
    var table = layui.table;         //表格
	var form = layui.form;           //表单
	var layer = layui.layer;         //弹层
    var exportData = {};
    var tableObj;
    layui.use(['table','form'], function() {
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: {
                limit:  20,
                limits: [ 10, 15,  30,  60,  90,  200,  400],
                curr: localStorage. getItem( "spgl_curr")? localStorage. getItem( "spgl_curr"): 1
            }
            ,limit: 20
            ,skin: 'row'
            ,even: true
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,title:'用户订单列表'
            // ,totalrow:true
            ,defaultToolbar: ['filter']
            ,cols: [[ //表头
                {field: 'id', title: '订单ID',width:50}
                ,{field: 'orders_id', title: '订单号',width:100}
                ,{field: 'nickname', title: '买家名称',width:100}
                ,{field: 'output_goods_name', title: '所购买产品',width:100}
                ,{field: 'goods_spec', title: '产品规格',width:100}
                ,{field: 'goods_num', title: '产品数量',width:100}
                ,{field: 'goods_price',title: '产品单价',width:100}
                ,{field: 'order_price',title: '订单总价',width:100}
                ,{field: 'order_status',title: '订单状态',width:100}
                ,{field: 'jifen',title: '使用积分',width:100}
                ,{field: 'jifen_price',title: '积分抵扣金额',width:100}
                ,{field: 'ctime',title: '下单时间',width:100}
                ,{field: 'pay_time',title: '支付时间',width:100}
                ,{field: 'name',title: '收件人姓名',width:100}
                ,{field: 'phone',title: '收件人电话',width:100}
                ,{field: 'province',title: '收件人省份',width:100}
                ,{field: 'city',title: '收件人城市',width:100}
                ,{field: 'district',title: '收件人区县',width:100}
                ,{field: 'address',title: '收件人具体地址',width:100}
                ,{field: 'waybill_id',title: '运单号',width:100}
                ,{field: 'pihao',title: '批号',width:100}
                ,{field: 'pihao_num',title: '批号数量',width:100}
                ,{field: 'fp_type',title: '发票类型',width:100}
                ,{field: 'fp_title',title: '发票抬头',width:100}
                ,{field: 'taxNumber',title: '税号',width:100}
                ,{field: 'companyAddress',title: '单位地址',width:100}
                ,{field: 'telephone',title: '单位电话',width:100}
                ,{field: 'bankName',title: '银行名称',width:100}
                ,{field: 'bankAccount',title: '银行账号',width:100}
                ,{field: 'kuaidi_name',title: '退换货快递名称',width:100}
                ,{field: 'kuaidi_num',title: '退换货快递单号',width:100}
                ,{field: 'price_change_user_name',title: '修改价格的人的姓名',width:100}
                ,{field: 'price_change_reason',title: '价格修改原因',width:100}
            ]]
            ,parseData: function(res) {
                exportData = res.data;
                
            }
            ,done: function(){
                if (typeof(layui.global.addTableTool) !== 'undefined') {
                    layui.global.addTableTool();
                }
            }
        });
    });

    

    

    function export_data(){
        // layer.alert('hello');
        console.log(exportData);
        table.exportFile('dataTable', exportData, 'xls');
    }
    //表格导出
	// $("#export-id").click(function(){
    //     layer.alert('hello');
	// 	// table.exportFile(tableObj.config.id, exportData, 'xls');
	// })

    layui.use('upload', function(){
        var upload = layui.upload; //得到 upload 对象
        //创建一个上传组件
        upload.render({
        elem: '#test1'
        ,url: '{:url("goods_import")}'
        ,method:'post'
        ,done: function(res){ //上传后的回调
            // console.log(res);
            if(res.status=='success'){
                layer.msg('导入成功');
                window.location.reload();
            }
            else{
                layer.msg(res.msg);
            }
        } 
        ,accept: 'file' //允许上传的文件类型
        //,size: 50 //最大允许上传的文件大小
        //,……
        })
    });

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#bg_time'
            ,type: 'datetime'
        });
    });

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#ed_time'
            ,type: 'datetime'
        });
    });
    
</script>